//# DatabaseInterface.js
//# NGJurassic
//#
//# Created by Washaq.Majeed on 5/4/11.
//# Copyright 2011 __MyCompanyName__. All rights reserved.


exports.PersistanceManager = Core.Class.singleton(
{
	classname: 'PersistanceManager',
	
	initialize: function()
	{
		
	},
	
	updateUser: function(data, callback)
	{
		var data = "shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background1shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background shop menu screen background2";
		if(data)
		{
			var entries = {
				'UserData': data
			};
			Social.Common.Appdata.updateEntries(entries, function(error, keys){
				if(error)
				{
					console.log("Zulu: Error in updating Entries "+error);
					for(var key in error)
					{
						console.log("Zulu: Single Entry for key "+key+" value "+error[key]);
					}
				} 
				else
				{
					console.log("Zulu: ENTRIES MADE");	
				}
			});
		}
	},
	
	getUser: function(callback)
	{
		var key = "UserData";
		var keys = [
				key
			];
		Social.Common.Appdata.getEntries(keys, function(error, entries){
			if(!error)
			{	
                var val = entries[key];
                console.log("Zulu: Single Entry for key "+key+" value "+val);
                callback(error, val);
                return;
			}
			callback(error, entries);
			
		});
	},
	
	removeUser: function()
	{
		var keys = [
				'UserData'
			];
		// Deletes one or more key/value pairs.
		Social.Common.Appdata.deleteEntries(keys, function(error, keys){
			if(!error)
			{
				console.log("Zulu: Entry Deleted");
			} 
			else
			{
				console.log("Zulu: ERRORRRRRRRR");
			}
		});
	},
	
	destroy: function()
	{
		
	}
	
});